﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IPConfig.aspx.cs" Inherits="Whir_System_Module_Config_IPConfig" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>IP设置</title>
    <link href="../../Skin/Default/Css/main.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
        if (top.location == self.location) { 
            top.location='../../Default.aspx';
        } 
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DADADA">
            <tr>
                <td height="26" colspan="2" align="left" class="form_title"><strong>IP设置</strong></td>
            </tr>
            <tr>
                <td width="130" align="center" class="form_tdText">全站来访限定方式 </td>
                <td align="left" class="form_td">
                    <asp:RadioButtonList ID="rblLimitWay_all" runat="server">
                        <asp:ListItem Value="1">不启用来访限定功能，任何IP都可以访问本站。</asp:ListItem>
                        <asp:ListItem Value="2">仅仅启用白名单，只允许白名单中的IP访问本站。</asp:ListItem>
                        <asp:ListItem Value="3">仅仅启用黑名单，只禁止黑名单中的IP访问本站。</asp:ListItem>
                        <asp:ListItem Value="4">同时启用白名单与黑名单，先判断IP是否在白名单中，如果不在，则禁止访问；如果在则再判断是否在黑名单中，如果IP在黑名单中则禁止访问，否则允许访问。</asp:ListItem>
                        <asp:ListItem Value="5">同时启用白名单与黑名单，先判断IP是否在黑名单中，如果不在，则允许访问；如果在则再判断是否在白名单中，如果IP在白名单中则允许访问，否则禁止访问。</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td height="30" align="center" class="form_tdText">全站IP段白名单 </td>
                <td align="left" class="form_td">起始IP：<asp:TextBox ID="txtStartIP1" runat="server"
                    Width="100" />
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtStartIP1"
                        Display="Dynamic" ErrorMessage="当前输入的IP格式不正确" ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>&nbsp;结尾IP：<asp:TextBox
                            ID="txtEndIP1" runat="server" Width="100" /><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtEndIP1"
                        Display="Dynamic" ErrorMessage="当前输入的IP格式不正确" ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>&nbsp;
                    <asp:Button ID="btnAdd1" runat="server" Text="添加" CssClass="btn_default" OnClick="btnAdd1_Click"
                        OnClientClick="return checkForm();" /><br>
                    <div id="div1" runat="server">
                        <table width="98%" cellpadding="3" cellspacing="1" border="0" bgcolor="gray">
                            <tr>
                                <td height="21" align="center" width="35%" bgcolor="#DADADA">起始IP</td>
                                <td align="center" width="35%" bgcolor="#DADADA">结尾IP</td>
                                <td align="center" width="30%" bgcolor="#DADADA">操作</td>
                            </tr>
                            <asp:Repeater ID="rIP1" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td height="21" align="center" bgcolor="white">
                                            <%# Eval("startIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <%# Eval("endIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <asp:LinkButton ID="lbnDelete1" runat="server" OnClick="lbnDelete1_Click" OnClientClick="return confirm('确定要删除吗?');"
                                                CommandArgument='<%# Eval("IPID") %>'>删除</asp:LinkButton>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                    </div>
                </td>
            </tr>
            <tr>
                <td height="30" align="center" class="form_tdText">全站IP段黑名单 </td>
                <td align="left" class="form_td">起始IP：<asp:TextBox ID="txtStartIP2" runat="server"
                    Width="100" />&nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator3"
                        runat="server" ControlToValidate="txtStartIP2" Display="Dynamic" ErrorMessage="当前输入的IP格式不正确"
                        ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>&nbsp;结尾IP：<asp:TextBox
                            ID="txtEndIP2" runat="server" Width="100" />&nbsp;<asp:RegularExpressionValidator
                                ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtEndIP2"
                                Display="Dynamic" ErrorMessage="当前输入的IP格式不正确" ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>
                    <asp:Button ID="btnAdd2" runat="server" Text="添加" CssClass="btn_default" OnClick="btnAdd2_Click"
                        OnClientClick="return checkForm2();" /><br>
                    <div id="div2" runat="server">
                        <table width="98%" cellpadding="3" cellspacing="1" border="0" bgcolor="gray">
                            <tr>
                                <td height="21" align="center" width="35%" bgcolor="#DADADA">起始IP</td>
                                <td align="center" width="35%" bgcolor="#DADADA">结尾IP</td>
                                <td align="center" width="30%" bgcolor="#DADADA">操作</td>
                            </tr>
                            <asp:Repeater ID="rIP2" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td height="21" align="center" bgcolor="white">
                                            <%# Eval("startIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <%# Eval("endIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <asp:LinkButton ID="lbnDelete2" runat="server" OnClick="lbnDelete2_Click" OnClientClick="return confirm('确定要删除吗?');"
                                                CommandArgument='<%# Eval("IPID") %>'>删除</asp:LinkButton>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                    </div>
                </td>
            </tr>
            <tr>
                <td align="center" class="form_tdText" style="height: 26px">后台来访限定方式 </td>
                <td align="left" class="form_td" style="height: 26px">
                    <asp:RadioButtonList ID="rblLimitWay_back" runat="server">
                        <asp:ListItem Value="1">不启用来访限定功能，任何IP都可以访问本站。</asp:ListItem>
                        <asp:ListItem Value="2">仅仅启用白名单，只允许白名单中的IP访问本站。</asp:ListItem>
                        <asp:ListItem Value="3">仅仅启用黑名单，只禁止黑名单中的IP访问本站。</asp:ListItem>
                        <asp:ListItem Value="4">同时启用白名单与黑名单，先判断IP是否在白名单中，如果不在，则禁止访问；如果在则再判断是否在黑名单中，如果IP在黑名单中则禁止访问，否则允许访问。</asp:ListItem>
                        <asp:ListItem Value="5">同时启用白名单与黑名单，先判断IP是否在黑名单中，如果不在，则允许访问；如果在则再判断是否在白名单中，如果IP在白名单中则允许访问，否则禁止访问。</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td height="30" align="center" class="form_tdText">后台IP段白名单 </td>
                <td align="left" class="form_td">起始IP：<asp:TextBox ID="txtStartIP3" runat="server"
                    Width="100" />&nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator5"
                        runat="server" ControlToValidate="txtStartIP3" Display="Dynamic" ErrorMessage="当前输入的IP格式不正确"
                        ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>
                    结尾IP：<asp:TextBox ID="txtEndIP3" runat="server" Width="100" />&nbsp;<asp:RegularExpressionValidator
                        ID="RegularExpressionValidator6" runat="server" ControlToValidate="txtEndIP3"
                        Display="Dynamic" ErrorMessage="当前输入的IP格式不正确" ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>
                    <asp:Button ID="btnAdd3" runat="server" Text="添加" CssClass="btn_default" OnClick="btnAdd3_Click"
                        OnClientClick="return checkForm3();" /><br>
                    <div id="div3" runat="server">
                        <table width="98%" cellpadding="3" cellspacing="1" border="0" bgcolor="gray">
                            <tr>
                                <td height="21" align="center" width="35%" bgcolor="#DADADA">起始IP</td>
                                <td align="center" width="35%" bgcolor="#DADADA">结尾IP</td>
                                <td align="center" width="30%" bgcolor="#DADADA">操作</td>
                            </tr>
                            <asp:Repeater ID="rIP3" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td height="21" align="center" bgcolor="white">
                                            <%# Eval("startIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <%# Eval("endIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <asp:LinkButton ID="lbnDelete3" runat="server" OnClick="lbnDelete3_Click" OnClientClick="return confirm('确定要删除吗?');"
                                                CommandArgument='<%# Eval("IPID") %>'>删除</asp:LinkButton>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                    </div>
                </td>
            </tr>
            <tr>
                <td height="30" align="center" class="form_tdText">后台IP段黑名单 </td>
                <td align="left" class="form_td">起始IP：<asp:TextBox ID="txtStartIP4" runat="server"
                    Width="100" />&nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator7"
                        runat="server" ControlToValidate="txtStartIP4" Display="Dynamic" ErrorMessage="当前输入的IP格式不正确"
                        ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>
                    结尾IP：<asp:TextBox ID="txtEndIP4" runat="server" Width="100" />&nbsp;<asp:RegularExpressionValidator
                        ID="RegularExpressionValidator8" runat="server" ControlToValidate="txtEndIP4"
                        Display="Dynamic" ErrorMessage="当前输入的IP格式不正确" ValidationExpression="^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"></asp:RegularExpressionValidator>
                    <asp:Button ID="btnAdd4" runat="server" Text="添加" CssClass="btn_default" OnClick="btnAdd4_Click"
                        OnClientClick="return checkForm4();" /><br>
                    <div id="div4" runat="server">
                        <table width="98%" cellpadding="3" cellspacing="1" border="0" bgcolor="gray">
                            <tr>
                                <td height="21" align="center" width="35%" bgcolor="#DADADA">起始IP</td>
                                <td align="center" width="35%" bgcolor="#DADADA">结尾IP</td>
                                <td align="center" width="30%" bgcolor="#DADADA">操作</td>
                            </tr>
                            <asp:Repeater ID="rIP4" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td height="21" align="center" bgcolor="white">
                                            <%# Eval("startIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <%# Eval("endIP") %>
                                        </td>
                                        <td align="center" bgcolor="white">
                                            <asp:LinkButton ID="lbnDelete4" runat="server" OnClick="lbnDelete4_Click" OnClientClick="return confirm('确定要删除吗?');"
                                                CommandArgument='<%# Eval("IPID") %>'>删除</asp:LinkButton>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                    </div>
                </td>
            </tr>
            <tr>
                <td height="30" align="center" class="form_tdText"></td>
                <td align="left" class="form_td">
                    <asp:Button ID="btnUpdate" runat="server" Text="保存到配置文件" CssClass="btn_default2"
                        OnClientClick="return confirm('确定要修改吗？');" OnClick="btnUpdate_Click" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

<script language="javascript" type="text/javascript" src="../../../Script/Validate.js"></script>

<script language="javascript">
function checkForm(){
        var vs = ["txtStartIP1|noNull|请输入起始IP！","txtEndIP1|noNull|请输入结尾IP！"]; 
        if(Validator(vs))
            return true;
        else 
            return false;    
}

function checkForm2(){
        var vs = ["txtStartIP2|noNull|请输入起始IP！","txtEndIP2|noNull|请输入结尾IP！"]; 
        if(Validator(vs))
            return true;
        else 
            return false;    
}

function checkForm3(){
        var vs = ["txtStartIP3|noNull|请输入起始IP！","txtEndIP3|noNull|请输入结尾IP！"]; 
        if(Validator(vs))
            return true;
        else 
            return false;    
}
function checkForm4(){
        var vs = ["txtStartIP4|noNull|请输入起始IP！","txtEndIP4|noNull|请输入结尾IP！"]; 
        if(Validator(vs))
            return true;
        else 
            return false;    
}
</script>

<script language="javascript" src="../../Js/common.js"></script>

<script type="text/javascript">initAutoFormStyle();</script>

